﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PearTunes.Client.PearTunesServiceReference;
using System.Windows.Media.Imaging;
using System.IO;
using System.Windows.Controls;

namespace PearTunes.Client
{
    public class LocalTrack : Track
    {
        public string Album { get; set; }
        public TagLib.IPicture Pic;
        public BitmapFrame BitPicture
        {
            get
            {
                if (Pic != null)
                {
                    MemoryStream stream = new MemoryStream(Pic.Data.Data);
                    return BitmapFrame.Create(stream);
                }
                else
                {
                    Stream stream = App.GetResourceStream(new Uri(@"CustomControls\nocoverart.png", UriKind.RelativeOrAbsolute)).Stream;
                    return BitmapFrame.Create(stream);
                }
            }
        }
        public Image AlbumArt
        {
            get
            {
                Image im = new Image();
                im.Source = BitPicture;
                return im;
            }
        }
        private TimeSpan length;
        public TimeSpan Length
        {
            get
            {

                return new TimeSpan(length.Hours, length.Minutes, length.Seconds);
            }
            set
            {
                length = value;
            }
        }
        public string LengthToString
        {
            get
            {
                return String.Format("{0}:{1}", length.ToString("mm"), length.ToString("ss"));
            }

        }
    }
}
